/*
 *  txdnet.cn tonydon
 * 
 */
package cn.txdnet.txcms.dao;

import cn.txdnet.txcms.domain.HotShop;
import cn.txdnet.txcms.dto.PageDTO;
import cn.txdnet.txcms.mapper.HotShopMapper;
import cn.txdnet.txcms.query.HotShopQuery;
import cn.txdnet.txcms.query.ViewHotShopQuery;
import cn.txdnet.txweb.utils.CollectionUtil;
import java.util.List;
import java.util.Map;

/**
 *
 * @author txdnet
 */
public class HotShopDAO extends MybatisBaseDAO{
    
    /**
     * 添加商铺
     * @param shop
     * @return 
     */
    public int insertHotShop(HotShop shop){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.insertHotShop(shop);
    }
    
    /**
     * 更新商铺信息
     * @param shop
     * @return 
     */
    public int updateHotShop(HotShop shop){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updateHotShop(shop);
    }
    
    /**
     * 更新发布状态
     * @param m
     * @return 
     */
    public int updatePubstate(Map<String,Object> m){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updatePubstate(m);
    }
    
    /**
     * 更新评论状态
     * @param m
     * @return 
     */
    public int updateCmtstate(Map<String,Object> m){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updateCmtstate(m);
    }
    
    /**
     * 更新发布时间
     * @param m
     * @return 
     */
    public int updatePubTime(Map<String,Object> m){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updatePubTime(m);
    }
    
    /**
     * 更新时间
     * @param m
     * @return 
     */
    public int updateTime(Map<String,Object> m){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updateTime(m);
    }
    
    /**
     * 批量更新类目
     * @param m
     * @return 
     */
    public int updateCatalog(Map<String,Object> m){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.updateCatalog(m);
    }
    
    /**
     * 删除商铺信息
     * @param ida
     * @return 
     */
    public int deleteHotShop(long[] ida){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.deleteHotShop(ida);
    }
    
    /**
     * 增加查看次数
     * @param shopid
     * @return 
     */
    public int increaseHitNum(long shopid){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.increaseHitNum(shopid);
    }
    /**
     * 查询商铺信息
     * @param query
     * @return 
     */
    public PageDTO queryByFactor(HotShopQuery query){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        query.filter();
        List list = mapper.listByFactor(query);
        if (query.getRownum().intValue() == 0 && CollectionUtil.isNotEmpty(list)) {
            query.setRownum(mapper.countByFactor(query));
        }
        return new PageDTO(list, query.getRownum());
    }
    
    /**
     * 查询商铺信息用于编辑
     * @param shopid
     * @return 
     */
    public HotShop queryShopForEdit(long shopid){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.queryShopForEdit(shopid);
    }
    
    /**
     * 查询商铺信息
     * @param query
     * @return 
     */
    public HotShop queryShopForView(ViewHotShopQuery query){
        HotShopMapper mapper = this.getMapper(HotShopMapper.class);
        return mapper.queryShopForView(query);
    }
}
